#!/bin/bash
#
echo ''
echo "`basename $0` ver 1.0"
echo 'Script to check the convergence w.r.t. plane wave energy cutoff.'
echo "Usage:"
echo "   `basename $0` eng_ecut.dat"
echo 'The first column should be cutoff energy in unit of eV,'
echo 'the second column should be energy/cell in unit of eV.'
echo ''
echo 'Author: LT Kong, konglt@sjtu.edu.cn'
echo ''

if [ ! -f "eng_ecut.dat" ]; then
 echo "`basename $0`"
 echo "A file named eng_ecut.dat is required, while not found."
 exit 1
fi
#
cat > .gnuplot.scr << EOF
set term post enha colo 20
set out 'conv_ecut.eps'

set xlabel 'E_{cutoff} (eV)'
set ylabel 'Energy (eV/cell)'

# set xtics 0.02
# set ytics 5

# set arrow 1 from 0,-2.5 to 0,2.5 lt 9 nohead

# set xr [-8:4]
# set yr [-2.5:2.5]

plot 'eng_ecut.dat' u 1:2 w lp pt 7 ps 2 t ''

# output a png file
set term png enha trans truec
set out "conv_ecut.png"
replot
EOF

# gnuplot is employed to draw the figure
gnuplot .gnuplot.scr;  rm -rf .gnuplot.scr
# visualize the figure by using gv
gv conv_ecut.eps

exit 0
